package com.iwayin.core.dao.notification;

import java.util.List;

import com.iwayin.core.dao.BaseDAOImpl;
import com.iwayin.core.dataobject.NotificationDO;

public class NotificationDAOImpl extends BaseDAOImpl implements NotificationDAO {

	@Override
	public Long addNotification(NotificationDO notification) {
		return (Long) this.getSqlMapClientTemplate().insert("NotificationDAO.addNotification", notification);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<NotificationDO> findNotificationByUserId(NotificationDO notification) {
		return this.executeQueryForList("NotificationDAO.findNotificationByUserId", "NotificationDAO.findNotificationByUserId.count", notification);
	}

	@Override
	public void deleteNotification(NotificationDO notification) {
		this.getSqlMapClientTemplate().delete("NotificationDAO.deleteNotification", notification);
	}

	@Override
	public Long addFansNotification(Long userId, Long objectId) {
		NotificationDO notification = new NotificationDO();
		notification.setUserId(userId);
		notification.setObjectId(objectId);
		notification.setType(NotificationDO.TYPE_FANS);
		return addNotification(notification);
	}

	@Override
	public Long addVoteNotification(Long userId, Long objectId) {
		NotificationDO notification = new NotificationDO();
		notification.setUserId(userId);
		notification.setObjectId(objectId);
		notification.setType(NotificationDO.TYPE_VOTE);
		return addNotification(notification);
	}

	@Override
	public Long addCommentNotification(Long userId, Long objectId) {
		NotificationDO notification = new NotificationDO();
		notification.setUserId(userId);
		notification.setObjectId(objectId);
		notification.setType(NotificationDO.TYPE_COMMENT);
		return addNotification(notification);
	}

}
